<extend name="Layout:layout_list" /><block name="head_after_block">
    <link href="__THEME__Plugin/jquery-audioplayer-1.0/jquery-audioplayer.css" rel="stylesheet" type="text/css"/>
</block>
<block name="body_content_block">
    <table id="main_grid" class="easyui-datagrid" data-url="{:AddonU('Statics/get_message_list_json')}"></table>
    <div id="tb" style="padding:2px 5px;">
        <div style="margin-bottom: 5px; border-bottom:solid 1px #dddddd;">
            <a href="#" class="easyui-linkbutton lnk_grid_search" iconCls="icon-search" plain="true">搜索</a>
        </div>
    </div>
    <!--隐藏区域-->
    <div style="display:none">
        <!--表格查询对话框-->
        <div id="dlg_search" style="padding:10px">
            <form method="get" action="{:AddonU('Statics/get_message_list_json')}" data-export-url="{:AddonU('Statics/message_export')}">
                <table class="search_table">
                    <tr><th>主叫：</th><td><input type="text" class="easyui-textbox" name="callerNo" /></td><th>被叫：</th><td><input type="text" class="easyui-textbox" name="dst" /></td></tr>
                    <tr><th>日期：</th><td><input type="text" name="date" class="easyui-datebox" /></td><th>工号：</th><td><input type="text" id="extension" name="extension" data-url="{:AddonU('Extension/get_extension_json')}" /></td></tr>
                    <tr><th>通话时长(大于/秒)：</th><td colspan="3"><input type="text" class="easyui-textbox" name="billsec" />(小于/秒)：<input type="text" class="easyui-textbox" name="billsecl" /></td></tr>
                    <if condition="$isSuperAdmin">
                        <tr><th>租户：</th><td colspan="3"><input type="text" id="siteID" name="siteID" data-url="{:AddonU('Admin/get_admin_json')}" /></td></tr>
                        <else/>
                        <tr style="display: none;"><td colspan="4"><input type="hidden" name="siteID" value="{$loginData.siteID}" /></td></tr>
                    </if>
                </table>
            </form>   
        </div>
        <!--/表格查询对话框-->
    </div>
    <!--/隐藏区域-->
</block>
<block name="body_after_block">
    <script type="text/javascript">
        // 页面初始化
        var curd_grid = CurdGrid.newInstance();
        curd_grid.before_search_dialog = function () {
            $('#siteID').combobox({url: $('#siteID').data('url'), valueField: 'id', textField: 'text',
                onSelect: function (val) {
                    after_siteID(val.id);
                }});

            $('#strategy').combobox({url: $('#strategy').data('url'), valueField: 'id', textField: 'text',
                onSelect: function (val) {
                    after_strategy(val.id);
                }});
            $('#extension').combobox({url: $('#extension').data('url'), valueField: 'id', textField: 'text'});
        }
        curd_grid.config({
            title: '留言查询',
            toolbar: '#tb',
            fitColumns: true,
            showFooter: true,
            columns: [[
                    {title: "租户ID", field: "siteIDText", sortable: true},
                    {title: "主叫号码", field: "callerNo", sortable: true},
                    {title: "被叫号码", field: "dst", sortable: true},
                    {title: "工号", field: "extension", sortable: true},
                    {title: "方向", field: "directionText", sortable: true},
                    {title: "开始时间", field: "xcallAnswer", sortable: true},
                    {title: "结束时间", field: "end", sortable: true},
                    {title: "通话时长", field: "billsecText", sortable: true},
                    {title: "试听", field: "listenPath", formatter: function (value, row) {
                            if (!value) {
                                return '';
                            }
                            return '<div class="soplayer"><span class="playermask"><audio src="' + value + '" controls="controls">您的浏览器不支持播放器插件,请升级到IE10以上的浏览器版本或火狐、谷歌等现代浏览器</audio></span><i style="clearfix"></i></div>';
                        }},
                    {title: '下载', field: "downloadPath", formatter: function (value, row) {
                            if (!value) {
                                return '';
                            }
                            return '<a href="' + value + '" target="_blank" class="easyui-linkbutton">下载</a>';
                        }},
                    {title: "编号", field: "id", hidden: true},
                ]],
        });
        curd_grid.init();


        function after_siteID(siteID) {
            if (!siteID) {
                return;
            }
            $('#extension').combobox({url: $('#extension').data('url'), queryParams: {siteID: siteID}, valueField: 'id', textField: 'text'});
            $('#strategy').combobox({url: $('#strategy').data('url'), queryParams: {siteID: siteID}, valueField: 'id', textField: 'text'});
        }
        function after_strategy(tsid) {
            if (!tsid) {
                return;
            }
            $('#task').combobox({url: $('#task').data('url'), queryParams: {tsid: tsid}, valueField: 'id', textField: 'text'});
        }
    </script>
</block>